import React, { Component } from 'react';
import "./catelist.css"
import request from "../../api"

interface Props{

}
interface State{
    catelist:CateItem[]
}
interface CateItem{
    imgurl:string,
    title:string
}
class Catelist extends Component<Props,State> {
    constructor(props:Props){
        super(props);
        this.state = {
            catelist:[]
        }
    }
    // 请求分类详情列表
    componentDidMount():void{
        console.log(666);
        
        request.catelist.cate_list().then((ok)=>{
            this.setState({catelist:ok.data.data},()=>{
                console.log(this.state.catelist);
                
            })
        })
    }
    render() {
        return (
            <div className='catelist'>
                {
                    this.state.catelist.map((item,index)=>{
                        return(
                           <div className='cate' key={index}>
                                <img src={item.imgurl} alt="" />
                                <div>{item.title}</div>
                           </div>
                        )
                    })
                }
            </div>
        );
    }
}

export default Catelist;